package com.ruoyi.supplier.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.supplier.mapper.TbSupplierMapper;
import com.ruoyi.supplier.domain.TbSupplier;
import com.ruoyi.supplier.service.ITbSupplierService;

/**
 * 供应商Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-02-16
 */
@Service
public class TbSupplierServiceImpl implements ITbSupplierService 
{
    @Autowired
    private TbSupplierMapper tbSupplierMapper;

    /**
     * 查询供应商
     * 
     * @param id 供应商ID
     * @return 供应商
     */
    @Override
    public TbSupplier selectTbSupplierById(Long id)
    {
        return tbSupplierMapper.selectTbSupplierById(id);
    }

    /**
     * 查询供应商列表
     * 
     * @param tbSupplier 供应商
     * @return 供应商
     */
    @Override
    public List<TbSupplier> selectTbSupplierList(TbSupplier tbSupplier)
    {
        return tbSupplierMapper.selectTbSupplierList(tbSupplier);
    }

    /**
     * 新增供应商
     * 
     * @param tbSupplier 供应商
     * @return 结果
     */
    @Override
    public int insertTbSupplier(TbSupplier tbSupplier)
    {
        tbSupplier.setCreateTime(DateUtils.getNowDate());
        tbSupplier.setCreateBy(SecurityUtils.getUsername());
        return tbSupplierMapper.insertTbSupplier(tbSupplier);
    }

    /**
     * 修改供应商
     * 
     * @param tbSupplier 供应商
     * @return 结果
     */
    @Override
    public int updateTbSupplier(TbSupplier tbSupplier)
    {
        tbSupplier.setUpdateTime(DateUtils.getNowDate());
        tbSupplier.setUpdateBy(SecurityUtils.getUsername());
        return tbSupplierMapper.updateTbSupplier(tbSupplier);
    }

    /**
     * 批量删除供应商
     * 
     * @param ids 需要删除的供应商ID
     * @return 结果
     */
    @Override
    public int deleteTbSupplierByIds(Long[] ids)
    {
        return tbSupplierMapper.deleteTbSupplierByIds(ids);
    }

    /**
     * 删除供应商信息
     * 
     * @param id 供应商ID
     * @return 结果
     */
    @Override
    public int deleteTbSupplierById(Long id)
    {
        return tbSupplierMapper.deleteTbSupplierById(id);
    }
}
